<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes">
<title>新增收货地址</title>
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
<link rel="stylesheet" type="text/css" href="/static/css/shoujisc.css">
<script type="text/javascript" src="/static/js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="/static/js/woxiangyao.js"></script>
<script type="text/javascript" src="/static/js/TouchSlide.1.1.js"></script>
<script type="text/javascript" src="/static/js/foot.js"></script>
<script type="text/javascript" src="/static/js/myinit.js"></script>
<script type="text/javascript" src="/static/js/quyu.js"></script>

<style type="text/css">
	.mypageback{
		float:left;
	}

</style>
</head>

<body>
	
    <div class="sjsc-title1" style="height:45px">
    	<h3 class="sjsc-t1l f-l" style="height:45px;line-height:45px"><a class="mypageback"><span><</span>新增地址</a></h3>
        <button class="sjsc-btn1 f-r" id="cmf" style="width:60px;font-size:14px">保存</button>
        <div style="clear:both;"></div>
    </div>
    
    <ul style="font-size:14px;text-align:center">
    	<li>
        	<p class="xzdz-p1 f-l" style="margin-top:10px;margin-left:2.5%;margin-bottom:10px">收货人姓名</p>
            <input type="text" placeholder="请输入您的姓名" class="xzdz-ipt1 f-l" id="name" maxlength="8" style="width:95%;height:30px;line-height:30px;margin-left:2.5%;font-size:14px;border:1px solid #b4bd63"/>
            <div style="clear:both;"></div>            
        </li>
    	<li>
        	<p class="xzdz-p1 f-l" style="margin-top:10px;margin-left:2.5%;margin-bottom:10px">手机号码</p>
            <input type="tel" maxlength="11" placeholder="11位手机号" id="phone" class="xzdz-ipt1 f-l"  style="width:95%;height:30px;line-height:30px;margin-left:2.5%;font-size:14px;border:1px solid #b4bd63"/>
            <div style="clear:both;"></div>            
        </li>
    	<li style="height:auto">
        	<p class="xzdz-p1 f-l" style="margin-top:10px;margin-left:2.5%;">收货地址</p>
            <div class="xzdz-ipt2box f-l" style="margin-top:10px;margin-left:2.5%;margin-bottom:10px">
				<div>
					
					<select id="selProvince2" style="width:90px;height:30px;font-size:14px;border:1px solid #b4bd63" name="selProvince2"></select>
					  省
					
					<select id="selCity2" style="width:90px;height:30px;font-size:14px;border:1px solid #b4bd63"  name="selCity2"></select>
					  市
					
					<select id="selArea2" style="width:90px;height:30px;font-size:14px;border:1px solid #b4bd63"  name="selArea2"></select>
					 县/区
				</div>
            	 
                <div style="clear:both;"></div>
            </div>
            <div style="clear:both;"></div>            
        </li>
    	<li>
        	<p class="xzdz-p1 f-l" style="margin-left:2.5%;margin-bottom:10px">详细地址</p>
            <input type="text" placeholder="街道门牌信息" class="xzdz-ipt1 f-l" id="address" maxlength="64"  style="width:95%;height:30px;line-height:30px;margin-left:2.5%;font-size:14px;border:1px solid #b4bd63"/>
            <div style="clear:both;"></div>            
        </li>
		<!--
    	<li>
        	<p class="xzdz-p1 f-l">邮政编码</p>
            <input type="text" placeholder="邮政编码" class="xzdz-ipt1 f-l" id="youbian" maxlength="8"/>
            <div style="clear:both;"></div>            
        </li>
		-->
    </ul>
	
	<script type="text/javascript">
		var openid =getUrldata('OPENID');
		var id=-1;
		
		$('.mypageback').click(function(){
			window.history.go(-1);
		});
		
		
		function addOne(){
			var url = "/webserver/api/v1/custadr/";
			var aa={};
			aa.cityname=$('#selProvince2 option:checked').html()+$('#selCity2 option:checked').html()+$('#selArea2 option:checked').html();
			if(aa.cityname==''){
				alert('请输入所在省份城市与区域');
				return;
			}
			aa.custname=$('#name').val();
			if(aa.custname==''){
				alert('姓名不能为空');
				return;
			}
			aa.detailAdrinfo=$('#address').val();
			if(aa.detailAdrinfo==''){
				alert('地址不能为空');
				return;
			}
			aa.phoneno=$('#phone').val();
			if(aa.phoneno==''&&aa.phoneno.length!=11){
				alert('手机必须为11位的');
				return;
			}
			aa.wx_id=openid;
			dopost(url,aa,function(rs){
				if(rs.id!=null&&rs.id!=undefined&&rs.id!='null'&&rs.id!='undefined'){
					alert('添加成功');
					window.history.go(-1);
					
				}
		
			});
			
		
		}
		
		
		function save(){
		
			var url = "/webserver/api/v1/custadr/";
			var aa={};
			aa.cityname=$('#selProvince2 option:checked').html()+$('#selCity2 option:checked').html()+$('#selArea2 option:checked').html();
			if(aa.cityname==''){
				alert('请输入所在省份城市与区域');
				return;
			}
			aa.custname=$('#name').val();
			if(aa.custname==''){
				alert('姓名不能为空');
				return;
			}
			aa.detailAdrinfo=$('#address').val();
			if(aa.detailAdrinfo==''){
				alert('地址不能为空');
				return;
			}
			aa.phoneno=$('#phone').val();
			if(aa.phoneno==''&&aa.phoneno.length!=11){
				alert('手机必须为11位的');
				return;
			}
			aa.wx_id=openid;
			dopost(url,aa,function(rs){
				if(rs.id!=null&&rs.id!=undefined&&rs.id!='null'&&rs.id!='undefined'){
					alert('添加成功');
					window.history.go(-1);
					
				}
		
			});
		}
		
		$('#cmf').click(function(){
			addOne();
		});
		
		
		 
		 
		var b = AreaSelector({
			selProvinceId:'selProvince2',
			selCityId:'selCity2',
			selAreaId:'selArea2',
		    onProvinceChange:function(){
				//alert(this.options[this.selectedIndex].value);
			},
		    onCityChange:function(){
				//alert(this.options[this.selectedIndex].value);
			},
		    onAreaChange:function(){
				//alert(this.options[this.selectedIndex].value);
			}});
			b.initProvince(9,1,5);
		
	
	</script>
    
</body>
</html>
